﻿using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem;

namespace Peter.Net.CodeCompletion
{
   internal sealed class ImportCompletionData : EntityCompletionData
   {
      private readonly  string m_InsertUsing;
      private readonly string m_InsertionText;

      public ImportCompletionData (ITypeDefinition typeDef, CSharpTypeResolveContext contextAtCaret, bool useFullName)
         : base (typeDef)
      {
         this.Description = "using " + typeDef.Namespace + ";";
         if (useFullName)
         {
            var astBuilder = new TypeSystemAstBuilder (new CSharpResolver (contextAtCaret));
            m_InsertionText = astBuilder.ConvertType (typeDef).ToString ();
         }
         else
         {
            m_InsertionText = typeDef.Name;
            m_InsertUsing = typeDef.Namespace;
         }
      }
   }
}
